package com.sm.healthy.adapter

import android.graphics.Color
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.sm.healthy.R
import com.sm.healthy.data.bean.OxygenEntity
import com.sm.healthy.databinding.ItemHistoryOxygenBinding

/**
 * 历史数据列表
 */
class HistoryOxygenAdapter(
    layoutId: Int = R.layout.item_history_oxygen,
    list: MutableList<OxygenEntity> = arrayListOf()
) : BaseQuickAdapter<OxygenEntity, BaseDataBindingHolder<ItemHistoryOxygenBinding>>(
    layoutId,
    list
) {

    override fun convert(
        holder: BaseDataBindingHolder<ItemHistoryOxygenBinding>,
        item: OxygenEntity
    ) {
        holder.dataBinding?.oxygenValue = item

        when {
            item.levelOxygen <= 90 -> {
                holder.dataBinding?.textView14?.text = "↓"
                holder.dataBinding?.textView14?.setTextColor(Color.parseColor("#00aa11"))
            }
            item.levelOxygen in 91..139 -> {
                holder.dataBinding?.textView14?.text = ""

            }
            item.levelOxygen > 140 -> {
                holder.dataBinding?.textView14?.text = "↑"
                holder.dataBinding?.textView14?.setTextColor(Color.parseColor("#de253b"))
            }
        }
    }
}